{extend name="index/base" /}
{block name="style"}{/block}
{block name="body"}
<blockquote class="layui-elem-quote">请先去邮箱开启smtp服务</blockquote>
<fieldset class="layui-elem-field">
  <legend>邮件配置</legend>
  <div class="layui-field-box">
    <form class="layui-form" action="{:url('edit')}">
      <div class="layui-form-item">
        <label class="layui-form-label">选择邮箱：</label>
        <div class="layui-input-inline">
          <select name="config[mail_smtp]" lay-verify="required">
            <option value="">请选择</option>
            <option value="163">163邮箱</option>
            <option value="qq">qq邮箱</option>
            <option value="aliyun">阿里云邮箱</option>
          </select> 
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">邮箱账号：</label>
        <div class="layui-input-inline">
            <input type="text" name="config[mail_username]" required  lay-verify="required|email" placeholder="请输入登录账号" autocomplete="off" class="layui-input" value="{$config.mail_username}">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">密码/授权码：</label>
        <div class="layui-input-inline">
          <input type="text" name="config[mail_password]" required  lay-verify="required" placeholder="请输入密码/授权码" autocomplete="off" class="layui-input" value="{$config.mail_password}">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">设置发件人：</label>
        <div class="layui-input-inline">
            <input type="text" name="config[mail_sendname]" required  lay-verify="required" placeholder="例：顽兔流量" autocomplete="off" class="layui-input" value="{$config.mail_sendname}">
        </div>
      </div>

      <div class="layui-form-item">
        <div class="layui-input-block">
          <button class="layui-btn" lay-submit lay-submit="" lay-filter="ajax-post" type="submit" target-form="layui-form">立即提交</button>
          <button type="reset" class="layui-btn layui-btn-primary">重置</button>
          <a href="javascript:;" class="layui-btn layui-btn-primary" id="test">测一下</a>
        </div>
      </div>
    </form>
  </div>
</fieldset>

{/block}

{block name="script"}
<script type="text/javascript">
layui.config({
     base: '/static/js/',
});
layui.use(['tool'],function(){
	var $ = layui.jquery,layer = layui.layer,form = layui.form,tool = layui.tool;
	tool.setValue('config[mail_smtp]','{$config.mail_smtp}');
  $('#test').click(function(){
    layer.prompt({title:'请输入要接收的邮箱'},function(value, index, elem){
       $.post('{:url('email')}',{email:value},function(data){
           layer.msg(data.msg);
           layer.close(index);
       });
    });
  });
});
</script>
{/block}